﻿using System;
using System.Web;

using DreamCube.Foundation.Basic.Utility;

namespace DreamCube.Websites.UI.Common.Agents
{
    /// <summary>
    /// 获取服务器时间
    /// </summary>
    public class GetServerNowTime : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";

                //获取需要的日期格式
                String type = HttpUtility.UrlDecode(context.Request.QueryString["t"]);
                if (String.IsNullOrEmpty(type))
                    type = "yyyy-MM-dd";

                context.Response.Write(System.DateTime.Now.ToString(type));
            }
            catch (Exception ex)
            {
                MyLog.MakeLog(ex);
            }
            finally
            {
                context.Response.End();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}